@@ -402,12 +402,5 @@ class AgentDrop < Liquid::Drop |
||
402 | 402 |
def to_liquid |
403 | 403 |
AgentDrop.new(self) |
404 | 404 |
end |
405 |
- |
|
406 |
- def to_h |
|
407 |
- drop = to_liquid |
|
408 |
- AgentDrop.public_instance_methods(false).each_with_object({}) { |attr, hash| |
|
409 |
- hash[attr.to_s] = drop.__send__(attr) |
|
410 |
- } |
|
411 |
- end |
|
412 | 405 |
end |
413 | 406 |
end |
@@ -106,7 +106,7 @@ module Agents |
||
106 | 106 |
|
107 | 107 |
def receive(incoming_events) |
108 | 108 |
incoming_events.each do |event| |
109 |
- payload = perform_matching({ 'agent' => event.agent.to_h }.merge(event.payload)) |
|
109 |
+ payload = perform_matching(event.payload) |
|
110 | 110 |
opts = interpolated(EventDrop.new(event, payload)) |
111 | 111 |
formatted_event = opts['mode'].to_s == "merge" ? event.payload.dup : {} |
112 | 112 |
formatted_event.merge! opts['instructions'] |
@@ -8,8 +8,7 @@ describe Agents::EventFormattingAgent do |
||
8 | 8 |
:instructions => { |
9 | 9 |
:message => "Received {{content.text}} from {{content.name}} .", |
10 | 10 |
:subject => "Weather looks like {{conditions}} according to the forecast at {{pretty_date.time}}", |
11 |
- :agent_type => "{{agent.type}}", |
|
12 |
- :agent_type_via_matching => "{{agent_info.type}}", |
|
11 |
+ :agent => "{{agent.type}}", |
|
13 | 12 |
}, |
14 | 13 |
:mode => "clean", |
15 | 14 |
:matchers => [ |
@@ -18,11 +17,6 @@ describe Agents::EventFormattingAgent do |
||
18 | 17 |
:regexp => "\\A(?<time>\\d\\d:\\d\\d [AP]M [A-Z]+)", |
19 | 18 |
:to => "pretty_date", |
20 | 19 |
}, |
21 |
- { |
|
22 |
- :path => "{{agent.type}}", |
|
23 |
- :regexp => "\\A(?<type>.*)\\z", |
|
24 |
- :to => "agent_info", |
|
25 |
- }, |
|
26 | 20 |
], |
27 | 21 |
:skip_created_at => "false" |
28 | 22 |
} |
@@ -70,13 +64,12 @@ describe Agents::EventFormattingAgent do |
||
70 | 64 |
it "should handle Liquid templating in instructions" do |
71 | 65 |
@checker.receive([@event]) |
72 | 66 |
Event.last.payload[:message].should == "Received Some Lorem Ipsum from somevalue ." |
73 |
- Event.last.payload[:agent_type].should == "WeatherAgent" |
|
67 |
+ Event.last.payload[:agent].should == "WeatherAgent" |
|
74 | 68 |
end |
75 | 69 |
|
76 | 70 |
it "should handle matchers and Liquid templating in instructions" do |
77 | 71 |
@checker.receive([@event]) |
78 | 72 |
Event.last.payload[:subject].should == "Weather looks like someothervalue according to the forecast at 10:00 PM EST" |
79 |
- Event.last.payload[:agent_type_via_matching].should == "WeatherAgent" |
|
80 | 73 |
end |
81 | 74 |
|
82 | 75 |
it "should allow escaping" do |